<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: fight
  Date: 2019/9/20
  Time: 8:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
</head>

<c:forEach items="${rooms}" var="room">
<div class="room">
    <label>房间<span>${room.roomId}</span></label>
    <c:if test="${room.users.size()==2}">
        <span>已满</span>
    </c:if>
    <c:if test="${room.users.size()!=2}">
        <a href="javascript:void(0);" onclick="inRoom(${room.roomId})">进入</a>
    </c:if>
</div>
</c:forEach>



<script>

    $('#btn-outRoom').addClass('hide');
    $('#btn-createRoom').removeClass('hide');
    $('#btn-restart').removeClass('hide');
    //
    function inRoom(roomId) {
        $('#rooms').load('${pageContext.request.contextPath}/joinRoom?roomId=' + roomId);
        console.log('join....')
        setTimeout(function () {
            Chess.data.role = "other";
            Chess.data.myColor = "white";
        }, 1000);
    }

</script>